package com.meizu.asum.richtextsdk.span;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.support.v7.widget.DrawableUtils;
import android.telecom.Call;
import android.text.style.ImageSpan;
import android.text.style.StyleSpan;
import android.text.style.TextAppearanceSpan;
import android.util.Log;

import com.meizu.asum.richtextsdk.R;

/**
 * Description： <br>
 * User：Xie JunWen <br>
 * Email：v-xiejunwen@meizu.com <br>
 * CreateTime：2018/3/6  15:10 <br>
 * Remark：无
 */
public class TopicSpan extends TextAppearanceSpan {
    public TopicSpan(Context context, int appearance) {
        super(context, appearance);
    }
//    private String topic;
//
//    public TopicSpan(Context context, String topic) {
//        super(textToDrawable(topic));
//        this.topic = topic;
//    }
//
//    public static Drawable textToDrawable(String topic) {
//        Bitmap bitmap = Bitmap.createBitmap(200, 250, Bitmap.Config.ARGB_8888);
//        Canvas canvas = new Canvas(bitmap);
//
//        Paint paint = new Paint();
////        paint.setTextSize(65);
//        paint.setTextAlign(Paint.Align.LEFT);
//        paint.setColor(Color.GRAY);
//        Paint.FontMetrics fm = paint.getFontMetrics();
//        canvas.drawText(topic, 0, 145 + fm.top - fm.ascent, paint);
//        canvas.save();
//        Drawable drawableright = new ShapeDrawable();
//        drawableright.draw(canvas);
//        drawableright.setBounds(0, 0, drawableright.getMinimumWidth(), drawableright.getMinimumHeight());
//
//        return drawableright;
//    }
//
//    @Override
//    public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
//        super.draw(canvas, text, start, end, x, top, y, bottom, paint);
////        getDrawable().setBounds(0, 0, 100, 100);
////        paint.setColor(Color.BLUE);
////        Log.i("XJW", "s：" + start + "，e：" + end + "，x：" + x + "，t：" + top + "，y：" + y + "，b：" + bottom);
//        canvas.drawText(topic, start, end, x, y, paint);
//    }

    //    @Override
//    public void updateDrawState(TextPaint ds) {
//        ds.setFakeBoldText(true);
//        ds.setColor(Color.RED);
//        //FIXME 这里还可以做其他差异性设置（修改文字大小等）
//        super.updateDrawState(ds);
//    }
//
//    @Override
//    public void updateMeasureState(TextPaint paint) {
//        paint.setFakeBoldText(true);
//        super.updateMeasureState(paint);
//    }
}
